package com.tsunami.authority.enums.auth;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tsunami.base.BaseEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 应用类型
 * 类型分为 管理通用 、普通通用 、教育专用 、医药专用
 *
 * @author tnmi
 * @date 25 2022/8/25
 **/
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "应用类型-枚举")
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ApplicationType implements BaseEnum {
    /**
     * MANAGE_SUPER="超管专用"
     */
    MANAGE_SUPER("超管专用"),
    /**
     * MANAGE_COMM="管理通用"
     */
    MANAGE_COMM("管理通用"),
    /**
     * COMM="普通通用"
     */
    COMM("普通通用"),
    /**
     * EDU_SPECIFIC="教育专用"
     */
    SPECIFIC("行业专用"),
    ;

    @Schema(description = "描述")
    private String desc;


    public static ApplicationType match(String val, ApplicationType def) {
        for (ApplicationType enm : ApplicationType.values()) {
            if (enm.name().equalsIgnoreCase(val)) {
                return enm;
            }
        }
        return def;
    }

    public static ApplicationType get(String val) {
        return match(val, null);
    }

    public boolean eq(String val) {
        return this.name().equalsIgnoreCase(val);
    }

    public boolean eq(ApplicationType val) {
        if (val == null) {
            return false;
        }
        return eq(val.name());
    }


    @Override
    public String getCode() {
        return BaseEnum.super.getCode();
    }

    @Override
    public String getDesc() {
        return this.desc;
    }
}
